/**
 * 
 */
package com.clh.service.impl;

import java.util.List;

import com.clh.common.PageInfo;
import com.clh.dao.AnnouncementDao;
import com.clh.dao.impl.AnnouncementDaoImpl;
import com.clh.entity.Announcement;
import com.clh.service.AnnouncementService;

/**
 * @Description: 公告Service实现类
 * @author 邱凯臻
 * @date 2022年5月27日 下午4:17:26
 * @version v1.0
 */
public class AnnouncementServiceImpl implements AnnouncementService {
	private AnnouncementDao announcementDao = new AnnouncementDaoImpl();

	@Override
	public List<Announcement> findAll() {
		return announcementDao.findAll();
	}

	@Override
	public List<Announcement> findByCondition(Announcement announcement) {
		return announcementDao.findByCondition(announcement);
	}

	@Override
	public PageInfo<Announcement> findByPage(Announcement announcement, int pageNum, int pageSize, String startDate,
			String endDate) {

		// System.out.println("Service pageNum = " + pageNum);
		// System.out.println("Service pageSize = " + pageSize);

		List<Announcement> list = announcementDao.findByPage(announcement, pageNum, pageSize, startDate, endDate);
		Integer total = announcementDao.countByCondition(announcement, startDate, endDate);

		PageInfo<Announcement> pageInfo = new PageInfo<Announcement>(list, pageNum, pageSize, total);
		return pageInfo;

	}

	@Override
	public boolean add(Announcement announcement) {
		int num = announcementDao.add(announcement);
		if (num > 0) {
			return true;
		}
		return false;
	}

	@Override
	public boolean update(Announcement announcement) {
		int num = announcementDao.update(announcement);
		if (num > 0) {
			return true;
		}
		return false;
	}

}
